import request from '@/config/axios'

// 付款单 VO
export interface PaymentVO {
  id: number // 订单编号
  dispatchOrderNo: string // 派单订单no
  dispatchOrderId: number // 派单订单
  no: string // 订单编号
  remark: string // 备注
  status: number // 开启状态
  sort: number // 排序
  carType: string // 车型
  dispatchPrice: number // 付款金额
  discountPrice: number // 优惠金额
  payAccount: string // 付款账户
  payMode: boolean // 付款方式
  payDate: Date // 付款时间
  payStauts: boolean // 付款状态
  paidAmount: number // 已付金额
  unpaidAmount: number // 未付金额
  checkStatus: boolean // 对账状态
  checkDate: Date // 对账时间
}

// 付款单 API
export const PaymentApi = {
  // 查询付款单分页
  getPaymentPage: async (params: any) => {
    return await request.get({url: `/dispatch/payment/page`, params})
  },

  // 查询付款单详情
  getPayment: async (id: number) => {
    return await request.get({url: `/dispatch/payment/get?id=` + id})
  },

  getByDispatchOrderId: async (dispatchOrderId) => {
    return await request.get({url: `/dispatch/payment/getByDispatchOrderId/` + dispatchOrderId})
  },


  // 新增付款单
  createPayment: async (data: PaymentVO) => {
    return await request.post({url: `/dispatch/payment/create`, data})
  },
  //撤销付款
  cancelPay: async (id: number) => {
    return await request.put({url: `/dispatch/payment/cancelPay?id=` + id})
  },

  cancelCheck: async (id: number) => {
    return await request.put({url: `/dispatch/payment/cancelCheck?id=` + id})
  },


  bindBatch: async (batchId,data) => {
    return await request.put({url: `/dispatch/payment/bindBatch/` + batchId,data})
  },

  handleBatchCancelReconciliation: async (data) => {
    return await request.put({url: `/dispatch/payment/handleBatchCancelReconciliation`, data})
  },


  // 修改付款单
  updatePayment: async (data: PaymentVO) => {
    return await request.put({url: `/dispatch/payment/update`, data})
  },

  handlePay: async (data: PaymentVO) => {
    return await request.put({url: `/dispatch/payment/handlePay`, data})
  },
  //批量撤销付款
  batchCancelPay: async (data: PaymentVO) => {
    return await request.post({url: `/dispatch/payment/batchCancelPay`, data})
  },
  //批量付款
  handleBatchPay: async (data: PaymentVO) => {
    return await request.put({url: `/dispatch/payment/handleBatchPay`, data})
  },

  //批量对账
  handleBatchReconciliation: async (data: PaymentVO) => {
    return await request.put({url: `/dispatch/payment/handleBatchReconciliation`, data})
  },

  //批量驳回付款
  batchReject: async (data: PaymentVO) => {
    return await request.post({url: `/dispatch/payment/batchReject`, data})
  },

  // 删除付款单
  deletePayment: async (id: number) => {
    return await request.delete({url: `/dispatch/payment/delete?id=` + id})
  },

  // 导出付款单 Excel
  exportPayment: async (params) => {
    return await request.download({url: `/dispatch/payment/export-excel`, params})
  },
}
